package twentytwenty;

/**
 * @Author: Zahi
 * @Description:
 * @Date Created in 2020-12-04 14:31
 * @Modified By:
 */
public class IsPalindrome_125 {
    public static void main(String [] args){
        System.out.println(isPalindrome("abcba"));
    }

    public static boolean isPalindrome(String s) {
        StringBuilder stringBuilder = new StringBuilder();
        int length = s.length();
        for (int i = 0; i < length; i++) {
            char ch = s.charAt(i);
            // 判断字符是否为字母或者字符串
            if (Character.isLetterOrDigit(ch)){
                // 将大写的字母转换为小写的字母
                stringBuilder.append(Character.toLowerCase(ch));
            }
        }
        StringBuilder stringBuilder1 = new StringBuilder(stringBuilder).reverse();
        return stringBuilder.toString().equals(stringBuilder1.toString());
    }
}
